package xyz.poke.business.tool.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import xyz.poke.business.tool.common.Response;
import xyz.poke.business.tool.convert.UserConvert;
import xyz.poke.business.tool.param.UserParam;
import xyz.poke.business.tool.service.IUserService;
import xyz.poke.business.tool.utils.ResponseUtils;
import xyz.poke.business.tool.vo.UserVo;

/**
 * <p>
 * 商品基本信息表 前端控制器
 * </p>
 *
 * @author 迫壳
 * @since 2024-02-22
 */
@Controller
@RequestMapping("/user")
@ResponseBody
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/login")
    public Response<UserVo> login(@RequestBody @Validated UserParam param) {
        return ResponseUtils.ok(UserConvert.INSTANCE.toVo(userService.login(param)));
    }

    @PostMapping("register")
    public Response<Boolean> register(@RequestBody @Validated UserParam param) {
        return ResponseUtils.ok(userService.register(param));
    }

}
